// Coffee类，实现Beverage接口，代表咖啡
class Coffee implements Beverage {
    @Override
    public void prepare() {
        System.out.println("Preparing Coffee...");
    }
}

// Tea类，实现Beverage接口，代表茶
class Tea implements Beverage {
    @Override
    public void prepare() {
        System.out.println("Preparing Tea...");
    }
}

// BeverageFactory接口，工厂的接口，定义创建饮料的方法
interface BeverageFactory {
    Beverage createBeverage();  // 工厂方法，创建饮料
}

// CoffeeFactory类，创建咖啡的工厂
class CoffeeFactory implements BeverageFactory {
    @Override
    public Beverage createBeverage() {
        return new Coffee();  // 返回一个新的Coffee对象
    }
}

// TeaFactory类，创建茶的工厂
class TeaFactory implements BeverageFactory {
    @Override
    public Beverage createBeverage() {
        return new Tea();  // 返回一个新的Tea对象
    }
}

// 客户端代码，使用工厂获取饮料
public class Main {
    public static void main(String[] args) {
        // 创建Coffee工厂
        BeverageFactory coffeeFactory = new CoffeeFactory();
        // 使用工厂创建Coffee对象
        Beverage coffee = coffeeFactory.createBeverage();
        coffee.prepare();  // 输出: Preparing Coffee...

        // 创建Tea工厂
        BeverageFactory teaFactory = new TeaFactory();
        // 使用工厂创建Tea对象
        Beverage tea = teaFactory.createBeverage();
        tea.prepare();  // 输出: Preparing Tea...
    }
}